import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LIUYANJIAO
 * Date: 2024-09-18
 * Time: 23:23
 */
public class Del implements IOPeration{
    @Override
    public void work(bookList b) {
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入您要删除的图书的名字：");
        String name=scanner.nextLine();
        int pos=-1;
        int i=0;
        //找书
        for ( ; i < b.number; i++) {
            if(b.list[i].getBookName().equals(name)){
                pos=i;
                break;
            }
        }
        if(b.number==i){
            System.out.println("这里没有你要找的书");
            return;
        }
        //删书
        for (int i1 = pos; i1 < b.number-1; i1++) {
            b.list[pos]=b.list[pos+1];
        }
        b.number--;
        System.out.println("删除成功");

    }
}
